package com.dykj.fireFighting.server.base.dev.service.impl;

import com.dykj.fireFighting.api.base.dev.entity.DevHisFiles;
import com.dykj.fireFighting.api.base.dev.entity.DevHisWaterZc;
import com.dykj.fireFighting.api.base.dev.entity.DevHisZc;
import com.dykj.fireFighting.api.base.dev.service.IDevHisZcService;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.utils.DateUtil;
import com.dykj.fireFighting.common.core.utils.UUIDUtils;
import com.dykj.fireFighting.server.base.dev.mapper.DevHisFilesMapper;
import com.dykj.fireFighting.server.base.dev.mapper.DevHisZcMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * 电气火灾报警设备运行记录
 *
 * @Author LIJIANJIE
 * @Date  2021-07-12 15:10:02
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class DevHisZcServiceImpl extends BaseServiceImpl<DevHisZcMapper, DevHisZc> implements IDevHisZcService {
    @Autowired
    private DevHisFilesMapper devHisFilesMapper;

    @Override
    public int getElectricNum(String id) {
        return this.baseMapper.getElectricNum(id);
    }

    @Override
    public int getCurrentEleNum(String id) {
        return this.baseMapper.getCurrentEleNum(id);
    }

    @Override
    public int getUpEleNum(String s) {
        return this.baseMapper.getUpEleNum(s);
    }

    @Override
    public int getCenterEleNum(List<String> ids,String beginTime, String endTime) {
        return this.baseMapper.getCenterEleNum(ids,beginTime,endTime);
    }

    @Override
    public int getCenterCurrentEle(List<String> ids) {
        return this.baseMapper.getCenterCurrentEle(ids);
    }

    @Override
    public int getCenterUpEle(List<String> ids) {
        return this.baseMapper.getCenterUpEle(ids);
    }

    @Override
    public DevHisZc getElectricLimit(String relationId) {
        String tableName= "dev_his_zc_" + DateUtil.getYearWeek();
        return this.baseMapper.getElectricLimit(tableName,relationId);
    }

    @Override
    public int getEleByTime(String s, String beginTime, String endTime,String tableName) {
        return this.baseMapper.getEleByTime(s,beginTime,endTime,tableName);
    }

    @Override
    public void updateZc(DevHisWaterZc devHisWaterZc,String tableName) {

        DevHisZc devHisZc = new DevHisZc();
        devHisZc.setId(devHisWaterZc.getId());
        devHisZc.setFuheTime(devHisWaterZc.getFuheTime());
        devHisZc.setFuhePerson(devHisWaterZc.getFuhePerson());
        devHisZc.setFuhePersonId(devHisWaterZc.getFuhePersonId());
        devHisZc.setFuheContent(devHisWaterZc.getFuheContent());
        devHisZc.setIsEffective(devHisWaterZc.getIsEffective());
        devHisZc.setImportPart(devHisWaterZc.getImportPart());
        devHisZc.setStatus("1");
        this.baseMapper.updateByIdTable(devHisZc,tableName);
    }
}
